﻿using SqlSugar;
using System.ComponentModel.DataAnnotations.Schema;

namespace PLM.Service.CommomItem.Log.Dto {
    /// <summary>
    /// 
    /// </summary>
    [SugarTable("systemlog")]
    public class SystemLogModel {
        /// <summary>
        /// 主键
        /// </summary>
        [SugarColumn(ColumnName = "id", IsPrimaryKey = true, ColumnDataType = "varchar(4000)")]
        public string Id { get; set; }
        /// <summary>
        /// 日志分类 必填
        /// </summary>
        [SugarColumn(ColumnName = "category")]
        public int Category { get; set; }
        /// <summary>
        /// 功能模块 必填
        /// </summary>
        [SugarColumn(ColumnName = "functionmodule")]
        public int FunctionModule { get; set; }
        /// <summary>
        /// 日志记录时间 必填
        /// </summary>
        [SugarColumn(ColumnName = "createtime")]
        public DateTime CreateTime { get; set; } = DateTime.Now;
        /// <summary>
        /// 操作人Oid 必填
        /// </summary>
        [SugarColumn(ColumnName = "creator", ColumnDataType = "varchar(4000)")]
        public string Creator { get; set; }
        /// <summary>
        /// 操作用户信息 必填
        /// </summary>
        [SugarColumn(ColumnName = "creatorinfojson", ColumnDataType = "text")]
        public string CreatorInfoJson {
            get {
                if (CreatorInfo != null)
                    return Newtonsoft.Json.JsonConvert.SerializeObject(CreatorInfo);
                return null;
            }
            set {
                if (value != null)
                    CreatorInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<UserInfo>(value);
            }
        }
        /// <summary>
        /// 所属组织部门
        /// </summary>
        [SugarColumn(ColumnName = "organizationname", ColumnDataType = "varchar(4000)")]
        public string? OrganizationName { get; set; }
        /// <summary>
        /// 客户端ip
        /// </summary>
        [SugarColumn(ColumnName = "ipaddress", ColumnDataType = "varchar(4000)")]
        public string? IPAddress { get; set; }
        /// <summary>
        /// 客户端归属地
        /// </summary>
        [SugarColumn(ColumnName = "homeaddress", ColumnDataType = "varchar(4000)")]
        public string? HomeAddress { get; set; }
        /// <summary>
        /// 主机名称
        /// </summary>
        [SugarColumn(ColumnName = "host", ColumnDataType = "varchar(4000)")]
        public string? Host { get; set; }
        /// <summary>
        /// 浏览器
        /// </summary>
        [SugarColumn(ColumnName = "browser", ColumnDataType = "varchar(4000)")]
        public string? Browser { get; set; }
        /// <summary>
        /// 操作结果状态
        /// </summary>
        [SugarColumn(ColumnName = "operatestatus")]
        public int OperateStatus { get; set; }
        /// <summary>
        /// 操作结果信息
        /// </summary>
        [SugarColumn(ColumnName = "operateinfo", ColumnDataType = "varchar(4000)")]
        public string? OperateInfo { get; set; }
        /// <summary>
        /// 操作平台 
        /// </summary>
        [SugarColumn(ColumnName = "operateplatform")]
        public int OperatePlatform { get; set; }
        /// <summary>
        /// 操作对象名称
        /// </summary>
        [SugarColumn(ColumnName = "operateobjectname", ColumnDataType = "varchar(4000)")]
        public string? OperateObjectName { get; set; }
        /// <summary>
        /// 操作对象信息
        /// </summary>
        [SugarColumn(ColumnName = "operateobjectjson", ColumnDataType = "text")]
        public string? OperateObjectJson {
            get {
                if (OperateObject != null)
                    return Newtonsoft.Json.JsonConvert.SerializeObject(OperateObject);
                return null;
            }
            set {
                if (value != null)
                    OperateObject = Newtonsoft.Json.JsonConvert.DeserializeObject(value);
            }
        }
        /// <summary>
        /// 操作对象类型
        /// </summary>
        [SugarColumn(ColumnName = "operateobjectclass", ColumnDataType = "varchar(4000)")]
        public string? OperateObjectClass { get; set; }
        /// <summary>
        /// 操作对象类型名称
        /// </summary>
        [SugarColumn(ColumnName = "operateobjectclassname", ColumnDataType = "varchar(4000)")]
        public string? OperateObjectClassName { get; set; }
        /// <summary>
        /// 操作对象代号
        /// </summary>
        [SugarColumn(ColumnName = "operateobjectid", ColumnDataType = "varchar(4000)")]
        public string? OperateObjectId { get; set; }
        /// <summary>
        /// 操作内容
        /// </summary>
        [SugarColumn(ColumnName = "operatecontent", ColumnDataType = "varchar(4000)")]
        public string? OperateContent { get; set; }
        /// <summary>
        /// 操作类型
        /// </summary>
        [SugarColumn(ColumnName = "operatetype")]
        public int OperateType { get; set; }

        /// <summary>
        /// 接口名称
        /// </summary>
        [SugarColumn(ColumnName = "interfacename", ColumnDataType = "varchar(4000)")]
        public string? InterfaceName { get; set; }

        /// <summary>
        /// 接口地址
        /// </summary>
        [SugarColumn(ColumnName = "interfaceaddress", ColumnDataType = "varchar(4000)")]
        public string? InterfaceAddress { get; set; }

        /// <summary>
        /// 请求方式
        /// </summary>
        [SugarColumn(ColumnName = "requestmethod", ColumnDataType = "varchar(4000)")]
        public string? RequestMethod { get; set; }

        /// <summary>
        /// 请求参数
        /// </summary>
        [SugarColumn(ColumnName = "requestparameterjson", ColumnDataType = "text")]
        public string? RequestParameterJson {
            get {
                if (RequestParameter != null)
                    return Newtonsoft.Json.JsonConvert.SerializeObject(RequestParameter);
                return null;
            }
            set {
                if (value != null)
                    RequestParameter = Newtonsoft.Json.JsonConvert.DeserializeObject(value);
            }
        }

        /// <summary>
        /// 请求时间
        /// </summary>
        [SugarColumn(ColumnName = "requesttime")]
        public DateTime RequestTime { get; set; }

        [SugarColumn(ColumnName = "responsetime")]
        public DateTime ResponseTime { get; set; }

        [SugarColumn(ColumnName = "responsecontentjson", ColumnDataType = "text")]
        public string? ResponseContentJson {
            get {
                if (ResponseContent != null)
                    return Newtonsoft.Json.JsonConvert.SerializeObject(ResponseContent);
                return null;
            }
            set {
                if (value != null)
                    ResponseContent = Newtonsoft.Json.JsonConvert.DeserializeObject(value);
            }
        }

        [SugarColumn(ColumnName = "errorcontentjson", ColumnDataType = "text")]
        public string? ErrorContentJson {
            get {
                if (ErrorContent != null)
                    return Newtonsoft.Json.JsonConvert.SerializeObject(ErrorContent);
                return null;
            }
            set {
                if (value != null)
                    ErrorContent = Newtonsoft.Json.JsonConvert.DeserializeObject(value);
            }
        }
        /// <summary>
        /// 总成标记
        /// </summary>
        [SugarColumn(ColumnName = "assemblycode", ColumnDataType = "varchar(4000)")]
        public string? AssemblyCode { get; set; }
        #region 映射描述
        /// <summary>
        /// 操作用户信息 必填
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public UserInfo CreatorInfo { get; set; }

        [SugarColumn(IsIgnore = true)]
        public object OperateObject { get; set; }

        [SugarColumn(IsIgnore = true)]
        public object RequestParameter { get; set; }

        [SugarColumn(IsIgnore = true)]
        public object ResponseContent { get; set; }

        [SugarColumn(IsIgnore = true)]
        public object ErrorContent { get; set; }

        #endregion

    }

    /// <summary>
    /// 版 本 V1
    /// Copyright (c) 2020-2020 江苏互道科技有限公司
    /// 创建人：互道-开发组
    /// 日 期：2017.03.08
    /// 描 述：当前上下文执行用户信息
    /// </summary>
    public class UserInfo {
        #region 用户信息

        /// <summary>
        /// 用户主键
        /// </summary>		
        public string UserOid { get; set; }
        /// <summary>
        /// 用户账号
        /// </summary>	
        public string UserId { get; set; }
        /// <summary>
        /// 登录密码
        /// </summary>		
        public string Password { get; set; }
        /// <summary>
        /// 密码秘钥
        /// </summary>	
        //public string secretkey { get; set; }
        /// <summary>
        /// 真实姓名
        /// </summary>
        public string UserName { get; set; }
        /// <summary>
        /// 呢称
        /// </summary>	
        //public string nickName { get; set; }
        /// <summary>
        /// 头像
        /// </summary>	
        //public string headIcon { get; set; }
        /// <summary>
        /// 性别
        /// </summary>	
        public string Gender { get; set; }
        /// <summary>
        /// 手机
        /// </summary>	
        public string Phone { get; set; }
        /// <summary>
        /// 电话
        /// </summary>		
        //public string Phone { get; set; }
        /// <summary>
        /// 电子邮件
        /// </summary>	
        public string Email { get; set; }
        /// <summary>
        /// QQ号
        /// </summary>		
        //public string oICQ { get; set; }
        /// <summary>
        /// 微信号
        /// </summary>	
        //public string weChat { get; set; }
        /// <summary>
        /// 公司主键
        /// </summary>		
        //public string OrgId { get; set; }
        /// <summary>
        /// 所在公司及下属公司
        /// </summary>
        //public List<string> companyIds { get; set; }
        /// <summary>
        /// 部门主键
        /// </summary>		
        public string OrgId { get; set; }
        /// <summary>
        /// 所在部门及下属部门
        /// </summary>
        //public List<string> departmentIds { get; set; }
        /// <summary>
        /// 单点登录标识
        /// </summary>		
        //public int OpenId { get; set; }
        /// <summary>
        /// 角色信息
        /// </summary>
        public string RoleId { get; set; }
        /// <summary>
        /// 岗位信息
        /// </summary>
        //public string postIds { get; set; }
        /// <summary>
        /// 是否是超级管理员
        /// </summary>
        public bool IsSystem { get; set; }
        #endregion

        #region 扩展信息
        /// <summary>
        /// 应用Id
        /// </summary>
        public string AppId { get; set; }
        /// <summary>
        /// 登录时间
        /// </summary>
        public DateTime LogTime { get; set; }
        /// <summary>
        /// 登录IP地址
        /// </summary>
        public string IPAddress { get; set; }
        /// <summary>
        /// 浏览器名称
        /// </summary>
        public string Browser { get; set; }
        /// <summary>
        /// 登录者标识
        /// </summary>
        public string LoginMark { get; set; }
        /// <summary>
        /// 票据信息
        /// </summary>
        public string Token { get; set; }
        /// <summary>
        /// 即时通讯地址
        /// </summary>
        public string ImUrl { get; set; }
        /// <summary>
        /// 流程实例Id
        /// </summary>
        public string WfProcessId { get; set; }
        /// <summary>
        /// 头像地址
        /// </summary>
        public string UserPhotoUrl { get; set; }
        /// <summary>
        /// 签名文件oid
        /// </summary>
        public string SignFileOid { get; set; }

        #endregion
    }
}
